home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_6_3.arc / HEAP3 < prev    next >
Text File  |  1988-04-05  |  1KB  |  53 lines

  1. Borland International's HEAP3. Copyright 1988 Borland
  2. International.  No commercial use of this code without express
  3. permission from Borland International.
  4.  
  5. Run this program under TP3.
  6.  
  7.   program Heap3; {$R-}
  8.   { Compile and run under both Turbo Pascal 3.0 and 4.0.
  9.     Runs faster under 3.0.
  10.   }
  11.  
  12.   const
  13.     ArraySize = 1000;
  14.  
  15.   type
  16.     Byte5 = array[1..5] of Byte;
  17.     Byte9 = array[1..9] of Byte;
  18.  
  19.     Ptr5 = ^Byte5;
  20.     Ptr9 = ^Byte9;
  21.  
  22.   var
  23.     P5: array[1..ArraySize] of Ptr5;
  24.     P9: array[1..ArraySize] of Ptr9;
  25.  
  26.     Q5: array[1..ArraySize] of Ptr5;
  27.  
  28.     I: Integer;
  29.  
  30.     Timer: Integer absolute $40:$6C;
  31.     Start: Integer;
  32.  
  33.   begin
  34.     WriteLn('Start');
  35.     Start := Timer;
  36.  
  37.     for I := 1 to ArraySize do         { allocation loop }
  38.     begin
  39.       New(P5[I]);
  40.       New(P9[I]);
  41.     end;
  42.  
  43.     for I := ArraySize downto 1 do     { fragmentation loop }
  44.     begin
  45.       Dispose(P9[I]);
  46.       New(Q5[I]);
  47.       Dispose(P5[I]);
  48.     end;
  49.  
  50.     Writeln('Done in ',(Timer-Start)/18.2:0:1,' seconds.');
  51.   end.
  52.  
  53.